#ifndef PHP_PHPFOCUSLISTENER_HPP
#define PHP_PHPFOCUSLISTENER_HPP

#include <string>

#include "guichan/focuslistener.hpp"
#include "guichan/platform.hpp"

#include "php_guichan.h"

namespace php
{
    class GCN_CORE_DECLSPEC PhpFocusListener : 
        public FocusListener
    {
    public:
        /**
         * Constructor.
         */
        PhpFocusListener(void *phpcallback) {
            php_callback *t;
            t=(php_callback *)phpcallback;
        	call=t->callback;
        	params=t->params;
        	
        	MAKE_STD_ZVAL(retval);
        }

        // Inherited from FocusListener
        void focusLost(const Event& event) {
            zval *obj,*fun;
	        Uint32 returns;
	        
	        TSRMLS_FETCH();
	        

                //mCaretPosition = getFont()->getStringIndexAt(mText, mouseEvent.getX() + mXScroll);
                //fixScroll();
                
                /*switch(Z_TYPE_P(call)) {
            	case IS_ARRAY:
            		getArrayValueByIndex(*call,0,&obj);
            		getArrayValueByIndex(*call,1,&fun);
            		if (call_user_function(EG(function_table),&obj,fun,retval,1,&params TSRMLS_CC)) {
            			php_error(E_WARNING, "php_callback: callback failed");
            		}
            		break;
            	case IS_STRING:
            		if (call_user_function(EG(function_table),NULL,call,retval,1,&params TSRMLS_CC)) {
            			php_error(E_WARNING, "php_callback: callback failed");
            		}
            		break;
            	default:
            		php_error(E_WARNING, "php_callback: callback not accepted");
            		break;
            	}*/
            	//convert_to_long(retval);
            	//returns=Z_LVAL_P(retval);
            	//return returns;
        }

    protected:
    	zval *call;
    	zval *params;
    	zval *retval;
    };
}

#endif // end GCN_BUTTON_HPP
